import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { LoginComponent } from './pages/login/login/login.component';
import { RegistComponent } from './pages/login/regist/regist.component';
import { LayoutComponent } from './pages/layout/layout.component';
import { AuthGuard } from './utils/auth.guard';

const routes: Routes = [
  {
    path: '',
    component: LayoutComponent,
    canActivate: [AuthGuard],
    canActivateChild: [AuthGuard],
    children: [
      { path: '', pathMatch: 'full', redirectTo: '/home' },
      { path: 'pms', data: { breadcrumb: '商品' }, loadChildren: () => import('./pages/pms/pms.module').then(m => m.PmsModule) },
      { path: 'home', loadChildren: () => import('./pages/home/home.module').then(m => m.HomeModule) },
      { path: 'sms', data: { breadcrumb: '营销' }, loadChildren: () => import('./pages/sms/sms.module').then(m => m.SmsModule) },
      { path: 'ums', data: { breadcrumb: '权限' }, loadChildren: () => import('./pages/ums/ums.module').then(m => m.UmsModule) },
      { path: 'oms', data: { breadcrumb: '订单' }, loadChildren: () => import('./pages/oms/oms.module').then(m => m.OmsModule) },
    ]
  },
  { path: 'login', pathMatch: 'full', component: LoginComponent },
  { path: 'regist', pathMatch: 'full', component: RegistComponent },


];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule]
})
export class AppRoutingModule { }
